// 老师版本,跑不起来: Method handler for undefined already provided 第八行
const PROTO_FILE_PATH = 'src/main/protoBuf/Student.proto'
const grpc = require('grpc');
const grpcService = grpc.load(PROTO_FILE_PATH).com.shengsiyuan.proto;

var server = new grpc.Server();

server.addService(grpcService.StudentService.service,
    {getRealNameByUsername: getRealNameByUsername});
server.bind("localhost:8899", grpc.credentials.createInsecure());
server.start();

function getRealNameByUsername(call, callback) {
    console.log("call", call.request.username)

    //callback 回调函数,第一个对象是err,第二个对象是返回结果
    callback(null,{realname:"张三三"})
}